import { defineStore } from 'pinia'
import axios from 'axios'
interface User {
  id: number,
  name: string
}
export const useAccountStore = defineStore('account', {
  state: () => {
    return {
      tableData: <User[]>([])
    }
  },
  actions: {
    async deleteAccount(token: string, id: number) {
      const response = await axios.delete(`http://192.168.1.3:8000/admin/deleteUser/${id}`,
        { headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' } }
      )
      return response
    },
    async getAccount(token: string) {
      const response = await axios.get(`http://192.168.1.3:8000/admin/QueryAllUser`,
        { headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' } }
      )
      return response;
    },
    async resetAccount(token: string, id: number) {
      const response = await axios.put(`http://192.168.1.3:8000/reastPassword/${id}`,
        { headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' } }
      )
      return response;
    }
  }
})